static void gtk_button_style_set (GtkWidget * widget, GtkStyle * prev_style);
static void gtk_button_size_allocate (GtkWidget * widget,
GtkAllocation * allocation);
-static gint gtk_button_expose (GtkWidget * widget, GdkEventExpose * event);
+static gint gtk_button_draw (GtkWidget * widget, cairo_t *cr);
static gint gtk_button_button_press (GtkWidget * widget,
GdkEventButton * event);
static gint gtk_button_button_release (GtkWidget * widget,
widget_class->unmap = gtk_button_unmap;
widget_class->style_set = gtk_button_style_set;
widget_class->size_allocate = gtk_button_size_allocate;
- widget_class->expose_event = gtk_button_expose;
+ widget_class->draw = gtk_button_draw;
widget_class->button_press_event = gtk_button_button_press;
widget_class->button_release_event = gtk_button_button_release;
widget_class->grab_broken_event = gtk_button_grab_broken;
void
_gtk_button_paint (GtkButton *button,
- const GdkRectangle *area,
+ cairo_t *cr,
+ int width,
+ int height,
GtkStateType state_type,
GtkShadowType shadow_type,
const gchar *main_detail,
const gchar *default_detail)
{
GtkWidget *widget;
- gint width, height;
gint x, y;
GtkBorder default_border;
GtkBorder default_outside_border;
style = gtk_widget_get_style (widget);
window = gtk_widget_get_window (widget);
- x = allocation.x;
- y = allocation.y;
- width = allocation.width;
- height = allocation.height;
+ x = 0;
+ y = 0;
if (gtk_widget_has_default (widget) &&
GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
{
- gtk_paint_box (style, window,
+ gtk_cairo_paint_box (style, cr,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
- area, widget, "buttondefault",
+ widget, "buttondefault",
x, y, width, height);
x += default_border.left;
if (button->relief != GTK_RELIEF_NONE || button->depressed ||
gtk_widget_get_state(widget) == GTK_STATE_PRELIGHT)
- gtk_paint_box (style, window,
+ gtk_cairo_paint_box (style, cr,
state_type,
- shadow_type, area, widget, "button",
+ shadow_type, widget, "button",
x, y, width, height);
if (gtk_widget_has_focus (widget))
y += child_displacement_y;
}
- gtk_paint_focus (style, window,
+ gtk_cairo_paint_focus (style, cr,
gtk_widget_get_state (widget),
- area, widget, "button",
+ widget, "button",
x, y, width, height);
}
}
static gboolean
-gtk_button_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_button_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- if (gtk_widget_is_drawable (widget))
- {
- GtkButton *button = GTK_BUTTON (widget);
-
- _gtk_button_paint (button, &event->area,
- gtk_widget_get_state (widget),
- button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
- "button", "buttondefault");
-
- GTK_WIDGET_CLASS (gtk_button_parent_class)->expose_event (widget, event);
- }
+ GtkButton *button = GTK_BUTTON (widget);
+
+ _gtk_button_paint (button, cr,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget),
+ gtk_widget_get_state (widget),
+ button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
+ "button", "buttondefault");
+
+ GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr);
return FALSE;
}
};
-static gint gtk_toggle_button_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint gtk_toggle_button_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_toggle_button_pressed (GtkButton *button);
gobject_class->set_property = gtk_toggle_button_set_property;
gobject_class->get_property = gtk_toggle_button_get_property;
- widget_class->expose_event = gtk_toggle_button_expose;
+ widget_class->draw = gtk_toggle_button_draw;
widget_class->mnemonic_activate = gtk_toggle_button_mnemonic_activate;
button_class->pressed = gtk_toggle_button_pressed;
}
static gint
-gtk_toggle_button_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_toggle_button_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- if (gtk_widget_is_drawable (widget))
- {
- GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
- GtkButton *button = GTK_BUTTON (widget);
- GtkStateType state_type;
- GtkShadowType shadow_type;
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+ GtkButton *button = GTK_BUTTON (widget);
+ GtkStateType state_type;
+ GtkShadowType shadow_type;
- state_type = gtk_widget_get_state (widget);
-
- if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
- {
- if (state_type == GTK_STATE_ACTIVE)
- state_type = GTK_STATE_NORMAL;
- shadow_type = GTK_SHADOW_ETCHED_IN;
- }
- else
- shadow_type = button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
-
- _gtk_button_paint (button, &event->area, state_type, shadow_type,
- "togglebutton", "togglebuttondefault");
-
- if (child)
- gtk_container_propagate_expose (GTK_CONTAINER (widget), child, event);
- }
+ state_type = gtk_widget_get_state (widget);
+ if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
+ {
+ if (state_type == GTK_STATE_ACTIVE)
+ state_type = GTK_STATE_NORMAL;
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ }
+ else
+ shadow_type = button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+
+ _gtk_button_paint (button, cr,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget),
+ state_type, shadow_type,
+ "togglebutton", "togglebuttondefault");
+
+ if (child)
+ gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
+
return FALSE;
}